package com.tongyi.lizhishop.fragment;

import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.classic.common.MultipleStatusView;
import com.tongyi.lizhishop.beans.Item;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import com.tongyi.lizhishop.R;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class EvaluationFragment extends Fragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;
    @BindView(R.id.multiple_status_view)
    MultipleStatusView multipleStatusView;
    Unbinder unbinder;
    private String mParam1;
    private String mParam2;
    private int position;
    ArrayList itemDatas = new ArrayList();
    private CommonAdapter adapter;
    private BitmapDrawable mDivider;

    public EvaluationFragment() {

    }


    public static EvaluationFragment newInstance(int position, String param2) {
        EvaluationFragment fragment = new EvaluationFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PARAM1, position);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            position = getArguments().getInt(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_evaluation, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        multipleStatusView.showLoading();
        recyclerview.setLayoutManager(new LinearLayoutManager(this.getContext()));
        adapter = new CommonAdapter<Item>(getContext(), R.layout.fragment_evaluation_recycleview_item, itemDatas) {
            @Override
            protected void convert(ViewHolder holder, Item o, int position) {

            }
        };
        recyclerview.setAdapter(adapter);
        loadData();
    }

    private void loadData() {
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        itemDatas.add(new Item("adf"));
        multipleStatusView.showContent();
        adapter.notifyDataSetChanged();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
